<!-- include tpl=head -->
<script type="text/javascript">
var obj_upload = {};
var obj = art.dialog.opener;
$(document).ready(function(){
	cate_change();
});
function cate_change()
{
	val = $("#cate_id").val();
	if(!val){
		$.dialog.alert('请选择要存储的目标分类');
		return false;
	}
	var data = $("#cate_id option[value="+val+"]").attr('data');
	var catename = $("#cate_id option[value="+val+"]").attr('catename');
	obj_upload = new $.admin_upload({
		"multiple"	: 'true',
		"id" : "upload",
		'pick':{'id':'#upload_picker','multiple':true},
		'resize':false,
		"swf" : "js/webuploader/uploader.swf",
		"server": "{url ctrl=upload func=save/}",
		"filetypes" : "{$rs.ext}",
		'accept' : {'title':catename,'extensions':data},
		"formData" :{'{func session_name}':'{func session_id}','cateid':val},
		'fileVal':'upfile',
		'auto':false,
		"success":function(){
			return true;
		}
	});
	obj_upload.uploader.on('uploadFinished',function(){
		$.dialog.alert('附件上传成功',function(){
			obj.$.phpok.reload();
		});
	});
}
function save()
{
	
	var f = $("#upload_progress .phpok-upfile-list").length;
	if(f<1){
		$.dialog.alert('请选择要上传的文件');
		return false;
	}
	obj_upload.uploader.upload();
	return false;
}
function cancel()
{
	return obj_upload.uploader.stop();
}
</script>

<div class="table">
	<div class="title">
		{lang附件分类：}
		<span class="note">{lang请选择要上传的附件分类}</span>
	</div>
	<div class="content">
		<select id="cate_id" name="cate_id" onchange="cate_change()">
			<!-- loop from=$catelist key=$key value=$value -->
			<option value="{$value.id}"{if $value.is_default} selected{/if} data="{$value.filetypes}" catename="{$value.title}">
			{$value.title}<!-- if $value.typeinfos --> / {lang支持上传格式：}{$value.typeinfos}<!-- /if --></option>
			<!-- /loop -->
		</select>
	</div>
</div>
<div class="table">
	<div class="title">
		{lang选择要上传的文件：}
		<span class="note">{lang单个文件上传不能超过：}<span class="red">{func get_cfg_var upload_max_filesize}</span></span>
	</div>
	<div class="content"><div id="upload_picker" class=""></div></div>
</div>

<div class="table">
	<div class="content" id="upload_progress"></div>
</div>

<!-- include tpl=foot_open -->